/*
 * 创建日期 2005-10-7
 *
 * 更改所生成文件模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
package com.vanda.report.element;

import java.util.HashMap;

import org.apache.commons.validator.GenericValidator;

import com.vanda.report.ReportData;
import com.vanda.report.ReportException;
import com.vanda.report.ReportInnerData;
import com.vanda.report.Validation;

/**
 * @author wkf5985
 *
 * 更改所生成类型注释的模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
public class ReportElement extends Element {
	private String report_name;
	private String id;
	private String select_parameters;

	public void validator() throws ReportException {
		Validation.checkRequired("ReportElement", "report_name", report_name);
		Validation.checkRequired("ReportElement", "id", id);
	}

	/**
	 * 标签执行方法，递归执行
	 * @param obj
	 */
	public void execute(Object obj) throws ReportException {
		ReportData reportData = (ReportData) obj;

		try {
			ReportInnerData innerData = new ReportInnerData(reportData);

			innerData.setContextData(innerData);

			HashMap params = innerData.getHmParams();
			if (!GenericValidator.isBlankOrNull(select_parameters)) {
				params.put("select_parameters", select_parameters);
			}

			super.execute(innerData);

			innerData.setReportData(reportData);

		} catch (ReportException e) {
			throw e;
		} catch (Exception e) {
			throw new ReportException(e);
		}

	}

	/**
	 * @return
	 */
	public String getReport_name() {
		return report_name;
	}

	/**
	 * @param string
	 */
	public void setReport_name(String string) {
		report_name = string;
	}

	/**
	 * @return
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param string
	 */
	public void setId(String string) {
		id = string;
	}
	/**
	 * @return
	 */
	public String getSelect_parameters() {
		return select_parameters;
	}

	/**
	 * @param string
	 */
	public void setSelect_parameters(String string) {
		select_parameters = string;
	}

}
